<?php
namespace Home\Controller;
use Think\Controller;

class  AdminController extends Controller {

	public function index() {

		$this -> display();

	}

	public function login() {
		//登录验证 账号 yxcz_zqgame_admin 密码 03ADA24BA583645943AA87C68F42AC83 MAC地址

		if (I("post.username") != "11" || I("post.password") != "11")
			$this -> error("登录失败",U("admin/index"));
		else {
			session('username','yxcz_zqgame_admin');
			$this -> redirect("admin/admin");
		}

	}
	
	public function create_bonus(){
		$count=I("count");
		$money=I("money");
		
		$Bonus=M("bonus");
		
		$count_flag=1000;
		
		for ($i=0;$i<$count;$i++) {
			$data['money']=$money;
			$count_flag++;
			$data['code']="1262724001" . date("YmdGis") . $count_flag;
			$Bonus->add($data);
		}
		$this -> redirect("admin/admin");
		
		
	}
	
	public function logout() {
			session('username',null);
			$this -> redirect("admin/index");
		}

	

	public function admin() {
   
		if(session('username')!="yxcz_zqgame_admin")
		  $this->error("未登录",U("admin/index"));
		
		$Bonus=M("bonus");
		
	    $this->assign("list",$Bonus->select());
		
		$this -> display();

	}

}
?>